/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package hello;

import java.util.Timer;
import java.util.TimerTask;
import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Font;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.StringItem;

/**
 *
 * @author Arthur
 */
public class SplashScreen extends Canvas{

   
    private Display display;
    private Displayable next;
    private Timer timer = new Timer();
    private Image img;
    
    public SplashScreen(Display display, Displayable next){
        this.display = display;
        this.next = next;
        display.setCurrent(this);
        setFullScreenMode(true);
    }

    protected void paint(Graphics g) {
        try{
            img = Image.createImage("/hello/splash.png");
        }catch(Exception e){
            System.out.println("Erro ao Carregar imagem!!");
        }
        
        g.setColor (255, 250, 250) ; 
        g.fillRect(0, 0, getWidth(), getHeight());
        int x = (getWidth() / 2) - (img.getWidth() / 2);
        int y = (getHeight() / 2) - (img.getHeight() / 2);
        g.setFont(Font.getDefaultFont());
        g.drawImage(img, 20, 20,Graphics.HCENTER|Graphics.VCENTER);
        g.setColor(0,0,0);
        g.drawString("Versão 1.0", 90,15, Graphics.TOP | Graphics.HCENTER);
        g.drawString("AGENDA CM", 80,70, Graphics.TOP | Graphics.HCENTER);
        g.drawString("Alunos:", 40, 100, Graphics.TOP | Graphics.HCENTER);
        g.drawString("Arthur Cunha Costa", 80, 120, Graphics.TOP | Graphics.HCENTER);
        g.drawString("Eduardo Silva Rosa", 80, 140, Graphics.TOP | Graphics.HCENTER);
        g.drawString("Cláudio Douglas", 80, 160, Graphics.TOP | Graphics.HCENTER);
        
    }
    
    protected void showNotify(){
        int tempo = 5000;
        timer.schedule(new CountDown(), tempo);
    }
    
    public void dismiss(){
        timer.cancel();
        display.setCurrent(next);
    }

    private class CountDown extends TimerTask {

        public CountDown(){}

        public void run() {
            dismiss();
        }
    }
    
}
